import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score, classification_report

# 加载数据
data = pd.read_csv('homework/covid-19 symptoms dataset.csv')

# 预处理数据（例如，处理缺失值）
# data = preprocess_data(data)

# 选择特征和目标变量
X = data[['fever', 'bodyPain', 'age', 'runnyNose', 'diffBreath']]
y = data['infectionProb']

# 划分训练集和测试集
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# 创建逻辑回归模型
model = LogisticRegression()

# 训练模型
model.fit(X_train, y_train)

# 预测测试集
predictions = model.predict(X_test)

# 评估模型
print("Accuracy:", accuracy_score(y_test, predictions))
print(classification_report(y_test, predictions))

# 模型预测
y = model.predict([[104,1,35,0,1]])
print(y)